import request from '@/utils/request'
import axios from 'axios'
import {
  getToken
} from '@/utils/auth'
const serviceName = 'System'

export function queryTenantPower(Id) {
  return request({
    url: serviceName + '/System/QueryTenantPowerPage?Id=' + Id,
    method: 'get'
  })
}

export function saveTenantPower(data) {
  return request({
    url: serviceName + '/System/SaveTenantPower',
    method: 'post',
    data
  })
}

export function queryRolePower(data) {
  return request({
    url: serviceName + '/System/QueryRolePowerPage',
    method: 'post',
    data
  })
}

export function saveRolePower(data) {
  return request({
    url: serviceName + '/System/SaveRolePower',
    method: 'post',
    data
  })
}

export function uploadFile(file) {
  var param = new FormData()
  console.log(file)
  param.append('annoFile', file.file) // 自动上传
  return axios({
    baseURL: process.env.VUE_APP_BASE_API,
    url: 'Common/Upload/UploadFile',
    method: 'post',
    data: param,
    headers: {
      'Content-Type': 'multipart/form-data',
      'profile': getToken()
    }
  })
}

export function getOperationLog(data) {
  return request({
    url: serviceName + '/System/GetFieldOperationLog',
    method: 'post',
    data
  })
}

export function getMsgCount(data) {
  return request({
    url: serviceName + '/System/GetMessageCount',
    method: 'post',
    data
  })
}

export function queryDeskMenus(data) {
  return request({
    url: serviceName + '/System/QueryDeskTopMenus',
    method: 'post',
    data
  })
}

export function saveRowCover(data) {
  return request({
    url: serviceName + '/System/SaveRowCoverImg',
    method: 'post',
    data
  })
}

export function changeRowLock(data) {
  return request({
    url: serviceName + '/System/ChangeRowLock',
    method: 'post',
    data
  })
}

export default {
  queryTenantPower,
  saveTenantPower,
  queryRolePower,
  saveRolePower,
  uploadFile,
  getOperationLog,
  getMsgCount,
  queryDeskMenus,
  saveRowCover,
  changeRowLock
}
